package com.paff.mw;

import java.util.List;

import org.jbpm.api.Configuration;
import org.jbpm.api.ExecutionService;
import org.jbpm.api.HistoryService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.TaskService;
import org.jbpm.api.task.Task;

import com.paff.mw.types.ThesisProposal;

public class TaskHandler {
	public static void main(String[] args) {
		ProcessEngine engine = new Configuration().buildProcessEngine();
		TaskService taskService = engine.getTaskService();
		ExecutionService executionService = engine.getExecutionService();
		List<Task> pijoTasks = taskService.findPersonalTasks("pijo");
		for (Task task : pijoTasks) {
			ThesisProposal proposal = (ThesisProposal) taskService.getVariable(task.getId(), "proposal");
			proposal.setStatus(ThesisProposal.Status.accepted);
			taskService.completeTask(task.getId(),"accept");
		}
	}
}
